<?php 
if($session->check('Auth.User.id')){
	if($session->read('Auth.User.group') == 'admin' || $session->read('Auth.User.group') == 'manag')
	echo $this->element('toolbar',array('plugin' => 'gallery','category_id'=>$category_id));
}
?>


<?php 
if($session->check('Auth.User.id')){
	if($session->read('Auth.User.group') == 'admin' || $session->read('Auth.User.group') == 'manag')
	$this->Html->styleBlock("
		ul.file_toolbar { display: block; position: absolute; background: url(../../img/firma/bg_toolbar.png) repeat; margin: ".($params['border']+3)."px;  z-index: 1000; float: none; }
		ul.file_toolbar li { display: block; float: left; width: 16px; height: 16px; margin: 3px; padding: 2px; background: url(../../img/firma/bg_toolbar.png) repeat; }
		ul.file_toolbar li a { display: block; padding: 0px; margin: 0px; width: 16px; height: 16px; }
		ul.file_toolbar li a img { padding: 0px; margin: 0px;  }
		ul.file_toolbar li:hover { background: #fff; }
	",array('inline'=>false));
}?>

<?php if(is_array($items) && !empty($items)){?>

<?php foreach ($items as $key => $photo) {?>
	

	<?php
		$file = $fileUpload->image($photo['Upload']['name'],array('autoResize'=>true,'imagePathOnly'=>true,'class'=>'large','alt'=> $photo['Gallery']['name'],'width'=>800,'height'=>800));
		$thumb = $fileUpload->image($photo['Upload']['name'],array('autoResize'=>true,'imagePathOnly'=>true,'class'=>'thumb','alt'=> $photo['Gallery']['name'],'width'=>$params['width'],'height'=>$params['height']));
		$ext = strtolower($fileUpload->_getExt());
		 
		if($ext == '.jpg' || $ext == '.jpeg'  || $ext == '.gif' || $ext == '.png' || $ext == '.bmp'){
			
	?>
	

		
			<?php 
				if($session->check('Auth.User.id')){
					if($session->read('Auth.User.group') == 'admin' || $session->read('Auth.User.group') == 'manag'){
					echo "<div class=\"displayContainer\">";
					echo $this->element('file_toolbar',array('plugin' => 'gallery','category_id'=>$category_id,'gallery_id'=>$photo['Gallery']['id']));
					}
				}
			?>
			<?php echo $html->link(
		        	$html->image($thumb,array('class'=>'large','id'=>'work-'.$photo['Gallery']['id'],'alt'=>$photo['Gallery']['name']))
		        	,$file,array('escape'=>false,'class'=>"highslide",  'onclick'=>"return hs.expand(this)"))?>
		<?php 
			if($session->check('Auth.User.id')){
				if($session->read('Auth.User.group') == 'admin' || $session->read('Auth.User.group') == 'manag'){
					echo "</div>";
				}
			}
		?>
							
	<?php }else{?>
	<?php 
		if($ext == '.mov' || $ext == '.swf'  || $ext == '.flv' || $ext == '.avi' || $ext == '.mpg' || $ext == '.mpeg'){
			$rel = 'rel="prettyPhoto[gallery]"';
		}else{
			$rel = '';
		}
	?>
	<a href="<?php echo $file;?>" title="<?php echo $photo['Gallery']['name']?>" <?php echo $rel?> style="background: #fff; vertical-align: middle; "><br/><br/><?php echo '( '. $photo['Upload']['name'].' ) <br/><br/> <span style="text-decoration: none;  font-weight: normal;"  class="highslide"  onclick="return hs.expand(this)">'. $photo['Gallery']['name'].'</span>';?></a>
	<?php }?>	

<?php }?>

<?php }?>

